var __extends = (this && this.__extends) || function (d, b) {
    for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
    function __() { this.constructor = d; }
    d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
define(["require", "exports"], function (require, exports) {
    "use strict";
    var ZoomBlur = (function (_super) {
        __extends(ZoomBlur, _super);
        function ZoomBlur(quality) {
            if (quality === void 0) { quality = 20; }
            _super.call(this, "attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\nattribute vec4 aColor;\n\nuniform mat3 projectionMatrix;\n\nuniform vec2 center;\nuniform float strength;\nuniform vec2 texSize;\n\nvarying vec2 vCenter;\nvarying float vStrength;\nvarying vec2 vTexSize;\n\nvarying vec2 vTextureCoord;\nvarying vec4 vColor;\n\nvoid main(void)\n{\n\tgl_Position = vec4((projectionMatrix * vec3((aVertexPosition), 1.0)).xy, 0.0, 1.0);\n\tvTextureCoord = aTextureCoord;\n\n\tvCenter=center;\n\tvStrength=strength;\n\tvTexSize=texSize;\n\n    // vColor = vec4(aColor.rgb * aColor.a, aColor.a);\n\n}", "precision mediump float;\n\nvarying vec2 vCenter;\nvarying float vStrength;\nvarying vec2 vTexSize;\n\nvarying vec2 vTextureCoord;\n\nuniform sampler2D uSampler;\n\nfloat random(vec3 scale, float seed) {\n\t/* use the fragment position for a different seed per-pixel */\n\treturn fract(sin(dot(gl_FragCoord.xyz + seed, scale)) * 43758.5453 + seed);\n}\nvoid main() {\n\tvec4 color = vec4(0.0);\n\tfloat total = 0.0;\n\tvec2 toCenter = vCenter - vTextureCoord * vTexSize;\n\t\n\t/* randomize the lookup values to hide the fixed number of samples */\n\tfloat offset = random(vec3(12.9898, 78.233, 151.7182), 0.0);\n\t\n\tfor (float t = 0.0; t <= " + (quality = Math.max(1, ~~quality)) + ".0; t++) {\n\t\tfloat percent = (t + offset) / " + quality + ".0;\n\t\tfloat weight = 4.0 * (percent - percent * percent);\n\t\tvec4 sample = texture2D(uSampler, vTextureCoord + toCenter * percent * vStrength / vTexSize);\n\t\t\n\t\t/* switch to pre-multiplied alpha to correctly blur transparent images */\n\t\tsample.rgb *= sample.a;\n\t\t\n\t\tcolor += sample * weight;\n\t\ttotal += weight;\n\t}\n\t\n\tgl_FragColor = color / total;\n\t\n\t/* switch back from pre-multiplied alpha */\n\tgl_FragColor.rgb /= gl_FragColor.a + 0.00001;\n    // gl_FragColor = texture2D(uSampler, vTextureCoord);\n}", {
                center: { type: "v2", value: { x: 0, y: 0 } },
                strength: { type: 'f', value: 0 },
                texSize: { type: "v2", value: { x: 0, y: 0 } }
            });
            this._center = { x: 0, y: 0 };
        }
        ZoomBlur.prototype.applyFilter = function (renderer, input, output, clear) {
            var shader = this.getShader(renderer);
            this.uniforms.texSize.value = {
                x: 1,
                y: 1,
            };
            var _center = this._center;
            console.log(_center.x, input.size.width);
            this.uniforms.center.value = {
                x: _center.x / input.size.width,
                y: _center.y / input.size.height,
            };
            renderer.filterManager.applyFilter(shader, input, output, clear);
        };
        Object.defineProperty(ZoomBlur.prototype, "blur", {
            get: function () {
                return this.uniforms.strength.value;
            },
            set: function (value) {
                this.uniforms.strength.value = parseFloat(value) || 0;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(ZoomBlur.prototype, "center", {
            get: function () {
                return this._center;
            },
            set: function (value) {
                this._center.x = value.x;
                this._center.y = value.y;
            },
            enumerable: true,
            configurable: true
        });
        return ZoomBlur;
    }(PIXI.AbstractFilter));
    Object.defineProperty(exports, "__esModule", { value: true });
    exports.default = ZoomBlur;
});
